// written by Adam Barrer and Alex Keybl

#include "event.h"

Event::Event(){}

Event::Event(int day, double start, double end, const string& description)
: myDate(day), 
  myStart(start), 
  myEnd(end),
  myDescription(description),
  allDay(false)
  {
	unsigned int i=0;
	int sum=0;
	while(i<description.size()-1) {
		sum+=((int)description[i+1]%2+1)*(int)description[i]+((int)description[i]%2+2)*(int)description[i+1];
		i+=2;
	}
	
	myHash=sum;
}

Event::Event(int day, const string& description)
: myDate(day),
  myDescription(description),
  allDay(true)
{
	myStart = 0;
	myEnd = 24;
	
	unsigned int i=0;
	int sum=0;
	while(i<description.size()-1) {
		sum+=((int)description[i+1]%2+1)*(int)description[i]+((int)description[i]%2+2)*(int)description[i+1];
		i+=2;
	}
	
	myHash=sum;
}

int Event::getDay(){
	return myDate;	
}	

int Event::getHash(){
	return myHash;	
}	
		
double Event::getStart(){
	return myStart;
}	
		
double Event::getEnd(){
	return myEnd;
}	
		
string Event::getDescription(){
	return myDescription;
}	

string Event::printDay(){
	DayParser myDayParser=DayParser(myDate);
	DayTime myDayTime =DayTime(myDayParser.getYear(), myDayParser.getMonth(), myDayParser.getDay());
	cout<<myDate<<endl;
	cout<<myDayParser.getDayOfWeek()<<endl;
	return myDayParser.getDayOfWeek() + "  " + myDayTime.getFullDate();
}

bool Event::isAllDay(){
	return allDay;
}

bool Event::operator== (const Event& other)
{
	return ( (myHash==other.myHash) && (myEnd==other.myEnd)  && (myStart==other.myStart) 
		&& (myDate==other.myDate) && (allDay==other.allDay) );
}
